
using System;
using System.IO;
using System.Windows;
using System.Text;
using Qplus.beans;

namespace Qplus.Commands
{

    /**
     * 添加好友
     * 
     *
     */
    public class AddFriendCommand : AbsHeaderHttpCommand , HttpInputStreamProcessor{

        const string COMMAND = "AddFriend";
	    QUser user;
	    UserInfo friendInfo;
	    private long userID;

	    /**
	     * 
	     * @param uid
	     * @param UKEY
	     * @param user 自己
	     * @param o 好友列表变更观察者
	     * @param friendInfo 当前要添加的用户的信息如果为null将创建一个新的对象仅仅只有userID
	     */
	    public AddFriendCommand(String uid, String UKEY, QUser user, UserInfo friendInfo)
                :base(COMMAND, uid, UKEY)
        {
		    this.user = user;
		    this.friendInfo = friendInfo;
	    }
	
	    /**
	     * 
	     * @param uid
	     * @param UKEY
	     * @param user 自己
	     * @param o 好友列表变更观察者
	     * @param friendInfo 当前要添加的用户的信息如果为null将创建一个新的对象仅仅只有userID
	     */
	    public AddFriendCommand(long uid, byte[] UKEY, QUser user, UserInfo friendInfo)
            : base(COMMAND, uid.GetType().ToString(),  Encoding.UTF8.GetString(UKEY, 0, 32))
        {
		    this.user = user;
		    this.friendInfo = friendInfo;
	    }
	
	    /**
	     * 
	     * @param type 好友类型  0=好友
	     * @param friendID 好友id
	     */
	    public void set(int type, long friendID){
		    setFriendID(friendID);
		    setType(type);
	    }
	
	    private void setType(int type){
		    addParams("Type", type);
	    }
	
	    private void setFriendID(long friendID){
		    addParams("FriendID", friendID);
		    userID = friendID;
	    }

        public override Boolean processInputStream(Stream responseStream)
        {

           //TODO
   
            return true;
	    }

	   
	    public override void onSuccess(int code) {
	    }


	    public override void onFailed(int code) {
	    }

	    public HttpTask execute(String url) {
		    return base.execute(url, this);
	    }
    }

}